import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App.vue'
import Home from './pages/Home.vue'

Vue.config.productionTip = false
Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home
    },
    {
      path: '/list',
      name: 'List',
      component: () => import('./pages/List.vue')
    },
    {
      path: '/detail/:p/:age?',
      name: 'Detail',
      component: () => import('./pages/detail.vue')
    },
    {
      path: '/user',
      component: () => import('./pages/user.vue'),
      children: [
        {
          path: 'info',
          name: 'Info',
          component: () => import('./pages/user/Info.vue')
        },
        {
          path: 'changepwd',
          name: 'ChangePwd',
          component: () => import('./pages/user/ChangePwd.vue')
        },
        {
          path: 'orders',
          name: 'Orders',
          component: () => import('./pages/user/Orders.vue')
        },
        {
          path: 'score',
          name: 'Score',
          component: () => import('./pages/user/Score.vue')
        }
      ]
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('./pages/Login.vue')
    },
    {
      path: '*',
      component: () => import('./pages/NotFound.vue')
    }
  ]
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
